home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / util / dtype / AOM_Raw_dt40_2.lha / AOM_Raw_DT / Source / check.c < prev    next >
C/C++ Source or Header  |  1995-02-28  |  2KB  |  73 lines

  1.  
  2. /******************************************************************************
  3.  *
  4.  * Flowerpower's AOM_Raw Datatype
  5.  *
  6.  * Written by Christian Buchner and David N. Junod
  7.  *
  8.  ******************************************************************************
  9.  * check.c
  10.  *
  11.  */
  12.  
  13. #include <exec/types.h>
  14. #include <dos/dos.h>
  15. #include <dos/dosextens.h>
  16. #include <datatypes/datatypes.h>
  17. #include <graphics/gfx.h>
  18.  
  19. #include <clib/exec_protos.h>
  20. #include <clib/dos_protos.h>
  21. #include <clib/utility_protos.h>
  22.  
  23. #include <pragmas/exec_pragmas.h>
  24. #include <pragmas/dos_pragmas.h>
  25. #include <pragmas/utility_pragmas.h>
  26.  
  27. /*****************************************************************************/
  28.  
  29. #define SysBase          dthc->dthc_SysBase
  30. #define DOSBase          dthc->dthc_DOSBase
  31. #define UtilityBase      dthc->dthc_UtilityBase
  32.  
  33. /*****************************************************************************/
  34.  
  35. struct RawHeader
  36. {
  37.     ULONG width;
  38.     ULONG height;
  39.     ULONG depth;
  40. };
  41.  
  42. /*****************************************************************************/
  43.  
  44. BOOL __asm DTHook (register __a0 struct DTHookContext * dthc)
  45. {
  46.     BOOL retval = FALSE;
  47.     struct RawHeader *rh;
  48.     ULONG filesize;
  49.     
  50.     /* Make sure we have a FileInfoBlock */
  51.     if (dthc->dthc_FIB)
  52.     {
  53.         /* Make sure we have a buffer */
  54.         if (dthc->dthc_Buffer && dthc->dthc_BufferLength>=sizeof(struct RawHeader))
  55.         {
  56.             /* The buffer is the RawHeader */
  57.             rh=(struct RawHeader*)dthc->dthc_Buffer;
  58.             
  59.             /* Only allow depths of 5 and 6 */
  60.             if (rh->depth==5 || rh->depth==6)
  61.             {
  62.                 filesize=rh->depth*RASSIZE(rh->width,rh->height)+sizeof(struct RawHeader)+32*sizeof(UWORD);
  63.                 
  64.                 if (dthc->dthc_FIB->fib_Size == filesize)
  65.                 {
  66.                     retval=TRUE;
  67.                 }
  68.             }
  69.         }
  70.     }
  71.     return(retval);
  72. }
  73.